package org.paic.util.test

import org.paic.util.PropHelper

class PropHelperTest extends GroovyTestCase {
	String file = new File('src/test/resources/config').absolutePath

	void testLoadProperties(){
		def p = PropHelper.loadProperties('/config/datasource.properties')

		assert p.minimumPoolSize == '1'

		def p2 = PropHelper.loadProperties(file, PropHelper.SCOPE_ABS)

		assert p2.minimumPoolSize == '1'

		def p3 = PropHelper.loadProperties(file, 'dataSource.', PropHelper.SCOPE_ABS)
		assert p3.user == 'sa'
	}

	void testGetProperty(){
		String val = PropHelper.getProperty(file, 'minimumPoolSize', '0', PropHelper.SCOPE_ABS)
		assert val == '1'

		String val2 = PropHelper.getProperty(file, 'minimumPoolSize!', '0', PropHelper.SCOPE_ABS)
		assert val2 == '0'
	}
}